#include <PalindromeChecker.hpp>

unsigned PalindromeChecker::check(std::string word, long long *icount) {
	unsigned total(0u);
	long long myicount(0L);
	int i, j;
	// Navega pela palavra do comeco para o fim e do fim para o comeco
	// Caso os valores sejam simetricamente iguais, e' palindromo
	for (i = 0,	j = word.length()-1; 
		i < j; total += word[i++] + word[j--]) {
		myicount += 5L;
		if (word[i] != word[j]) {total = 0u; break;}
	}
	if (i == j) total += word[i], myicount++;
	if (icount) *icount += myicount;
	return total;
}
